<?php
if(!$Session->check_admin()) redirect('index.php');
require_once IMMOPHP_ROOT_PATH.'plugins/Page/lang/fr.php';
require_once IMMOPHP_ROOT_PATH.'plugins/Page/inc/Page.class.php';
if(isset($_POST['enregistrer'])) Page::add();
if(isset($_POST['enregistrer_edition'])) Page::edit();
if(isset($_GET['delete'])) Page::delete($_GET['page']);
if(isset($_GET['menu_add'])) Page::menu_add($_GET['page']);
$template->set_filenames(array('index' => 'plugins/Page/template/index.tpl'));

$Sql = $db->sql_query("SELECT * FROM immo_page ORDER BY name");
while($Page = $db->sql_fetchobject($Sql))
{
    $action = '<a href="plugins.php?plugins=Page&amp;p=edition&amp;page='.$Page->id.'"><img src="plugins/Page/images/edition.png" style="height:20px; width:20px; border:none;"/></a>&nbsp;&nbsp;';
    $action .= '<a href="javascript:delpage(\'' .$Page->id. '\');" title=""><img src="plugins/Page/images/delete.png" style="height:20px; width:20px; border:none;"/></a>&nbsp;&nbsp;';
    $action .= '<a href="plugins.php?plugins=Page&amp;menu_add&amp;page='.$Page->id.'"><img src="plugins/Page/images/menu_add.png" style="height:20px; width:20px; border:none;"/></a>';
    $template->assign_block_vars('page', array(
	'V_ID'	=>	$Page->id,
	'V_NAME'	=>	$Page->name,
	'V_LIEN'	=>	'page.php?page='.$Page->id,
	'V_DATE'	=>	date('d/m/Y', $Page->date_ajout),
    'V_ACTION'  =>  $action,
	));
}

$template->assign_vars(array(
'V_ZONE_CONTENUE'   =>  get_ckeditor('contenue',''),
'L_CONTENUE'    =>  $lang['Contenue'],
'L_NOM' =>  $lang['Nom'],
'L_GESTION_DES_PAGES'   =>  $lang['Gestion_des_pages'],
'L_TITRE'   =>  $lang['Titre'],
'L_LIEN'    =>  $lang['Lien'],
'L_DATE'    =>  $lang['Date'],
'L_ACTION'  =>  $lang['Action'],
'L_ENREGISTRER' =>  $lang['Enregistrer'],
'L_NOUVELLE_PAGE'   =>  $lang['Nouvelle_page'],
'L_CONFIRM_SUPPRESSION_PAGE'    =>  $lang['Confirmation_suppression_page'],
));
$template->display('index');
?>